﻿@using CQIE.OVS.Model
@model IList<CQIE.OVS.Model.Campaigner>

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/kj/layui/css/layui.css" rel="stylesheet" />
    <link href="~/CSS/Index.css" rel="stylesheet" />
</head>
<body>
    <div id="nav1">
        <img src="~/IMG/99999.jpg" alt="">
        <div id="nav">
            <p>@Model[0].Activity.Title</p>
        </div>
    </div>
    <div id="main">
        <div id="aside">
            <div id="aside11">
                @Model[0].Activity.Info
            </div>
            <h4>投票规则</h4>
            <div id="aside1">
                <div class="aide">
                    <p class="hh">(一)网络投票规则</p>
                    <p style="letter-spacing: 0px;"><span>1、</span>投票时间:@Model[0].Activity.DateStart.ToString()——@Model[0].Activity.DateEnd.ToString()</p>
                    <p><span>2、</span>投票方法:网友选中候选人,直接投票。</p>
                    <p><span>3、</span>投票次数限制:每天每用户限投1票。</p>
                    <p><span>4、</span>禁止刷票,发现后取消候选案名及报名者参赛资格。</p>
                </div>
                <div class="aide">
                    <p class="hh">(二)参与方式:</p>
                    <p class="aide1">&nbsp;&nbsp;本次比赛投票阶段设置了电脑参与方式：用手电脑访问指定链接，打开页面注册或登陆，进行投票。除此方式之外，其他任何方式的投票都不计入票数内。</p>
                </div>
            </div>
        </div>
        <div id="content">
            @{
                foreach (Campaigner item in Model)
                {
                    <div class="mydiv">
                        <div class="left">
                                        <div class="img">

                                            <img src="~/IMG/1111.png" style="width: 100%;height: 100%"/>
                                        </div>
                            <div class="name">@item.Name</div>
                        </div>
                        <div class="right">
                            热度:<span id="@item.ID">@item.Num</span>
                            <div lay-filter="@item.ID" style="margin-top: 10px; margin-bottom: 10px; margin-left: 5%; width: 90%;" class="layui-progress layui-progress-big">
                                <div class="layui-progress-bar layui-bg-red"></div>
                            </div>
                            <div class="Info">@item.Info</div>
                            <div>
                                <button class="layui-btn layui-btn-radius layui-btn-warm" value="@item.ID" id="zc" type="button">支持</button>
                                @Html.Hidden("CId", @item.ID)
                            </div>
                        </div>
                    </div>
                }
            }
        </div>
        <div id="login-boa">
            <div id="login-box">
                <div class="logined">
                    <p class="Welcome" style="font-size: 30px;">欢迎您!</p><br /><br/>
                    <p class="Accountss" style="font-size: 45px;color:#6A6AFF;"></p>
                    <button class="btn" type="button" id="logout">注销</button>
                </div>
                <div class="logindiv">
                    <p>登陆/Login</p>
                    <div class="textbox">
                        <input type="text" placeholder="UserName" name="account" value=""/>
                    </div>
                    <div class="textbox">
                        <input type="password" placeholder="Password" name="pwd" value=""/>
                    </div>
                    @*<input class="btn" type="submit" id="login" value="Start"/>*@
                    <button type="button" id="login" class="btn">Start</button><br />
                    <span id="errormsg" style="color: red; display: none;">用户名或密码错误</span>
                    <div id="logina"><a id="register" style="display: block;">现在注册?</a></div>
                </div>

            </div>
        </div>
        <div id="footer">
            <img src="~/IMG/09876.PNG" alt="">
        </div>
    </div>
    
    <script src="~/kj/layui/layui.js"></script>
    <script>
        layui.use(['element', 'jquery', 'layer', 'form'],
            function () {
                var element = layui.element;
                var $ = layui.jquery;
                var layer = layui.layer;

                function CountHot() {
                    $.post("/Home/CountHot",
                        { s: "d" },
                        function(msg) {
                            for (var i = 0; i < msg.length; i++) {
                                //console.log(msg[i]);
                                element.progress(msg[i].ID, msg[i].Hot);
                                var s = '#' + msg[i].ID;
                                console.log(s);
                                $(s).text(msg[i].Num);
                            }
                        });
                }
                CountHot();
                
                $("#register").click(function () {
                    layer.open({
                        title: '注册',
                        type: 1,
                        area: ['400px', '500px'],
                        resize: false,
                        anim: 1,
                        btnAlign: 'c',
                        btn: ['添加', '取消'],
                        content: '<div class="layui-form-item"><label class="layui-form-label">用户名</label><div class="layui-input-inline layui-col-md4"><input type="text" class="layui-input" name="Account"/></div></div><div class="layui-form-item  "><label class="layui-form-label">密码</label><div class="layui-input-inline layui-col-md4"><input type="password" class="layui-input" name="passwrod"/></div></div><div class="layui-form-item  "><label class="layui-form-label">确认密码</label><div class="layui-input-inline layui-col-md4"><input type="password" class="layui-input" name="passwrod2"/></div></div>',
                        btn1: function (index, layero) {
                            Account = $('[Name=Account]').val();
                            passwrod = $('[Name=passwrod]').val();
                            passwrod2 = $('[Name=passwrod2]').val();
                            if (passwrod == passwrod2) {
                                $.post("/Home/Register", {account: Account, pwd: passwrod, autoLogin: "Yes" },
                                    function (msg) {
                                        if (msg == 0) {
                                            layer.msg("用户名已存在，请重新输入！");
                                        }
                                        else if (msg==1) {
                                            layer.msg("注册成功！");
                                            setTimeout("layer.close(index);",1500);
                                        }
                                        else if (msg == 3) {
                                            $('.logindiv').hide();
                                            $('.logined').show();
                                            $('.Accountss').text(Account);
                                            layer.close(index);
                                        } else if (msg == 4) {
                                            layer.close(index);
                                            layer.msg("自动登录好像出了点问题！请自行登录");
                                        }
                                    });
                            }
                            else { layer.msg("两次密码不相同，请重新输入"); }
                        }
                    });
                    return false;
                });

                $('#login').click(function () {
                    var account = $('input[name=account]').val();
                    var pwd = $('input[name=pwd]').val();
                    $.post('/Home/Login',
                        { account: account, pwd: pwd },
                        function(msg) {
                            if (msg==0) {
                                $('#errormsg').show();
                            } else {
                                $('.logindiv').hide();
                                $('.logined').show();
                                $('.Accountss').text(account);
                            }
                            
                        });
                });

                $("#logout").click(function () {
                    $('.logined').hide();
                    $('.logindiv').show();
                    $.post('/Home/Logout',
                        {},
                        function() {
                            $('input').val('');
                        });
                });

                $('button#zc').click(function() {
                    var Cid = $(this).val();
                    $.post('/Home/VoteGo',
                        { CId: Cid },
                        function(msg) {
                            if (msg != "OK") {
                                layer.msg(msg);
                            } else {
                                layer.msg("感谢您的支持");
                            }
                            CountHot();
                        });
                });

            });
    </script>
</body>
</html>
